
<head>
    <meta charset="utf-8">
    {{--    <title>@yield('title')</title>--}}
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/Modules/system/layuimini/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/Modules/system/layuimini/css/public.css" media="all">

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js"></script>
</head>


<div class="layuimini-container">
    <div class="layuimini-main">

        <div class="layui-form-item">
            <label class="layui-form-label">昵称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="" class="layui-input name" value="{{$user['name']}}">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">原始密码</label>
            <div class="layui-input-block">
                <input type="password" name="oldPassword" placeholder="" autocomplete="off" class="layui-input oldPassword">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-block">
                <input type="password" name="password" placeholder="" autocomplete="off" class="layui-input password">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">确认新密码</label>
            <div class="layui-input-block">
                <input type="password" name="rePassword" placeholder="" autocomplete="off" class="layui-input rePassword">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
            </div>
        </div>

    </div>
</div>


<script>
    $(".layui-btn").click(function () {
        $.ajax({
            type: "POST",
            url: "/chinadmin/admin/user/changePassword",
            timeout: 100000, //超时时间设置，单位毫秒 为一秒
            data: {
                name: $(".name").val(),
                oldPassword: $(".oldPassword").val(),
                password: $(".password").val(),
                rePassword: $(".rePassword").val(),
            },
            dataType: "json",      //如果有此选项成功返回的json会自动变成对象，如果没有需要用JSON.parse()转换
            success: function (data) {
                console.log(data);

                layer.msg(data.msg);

            }
        });
    })
</script>